//
// Created by ChenJi on 2021/3/25.
//

#ifndef SCREENSPITEST_LCD_EXTERN_H
#define SCREENSPITEST_LCD_EXTERN_H

#endif //SCREENSPITEST_LCD_EXTERN_H

#include "main.h"
#include "lcd_init.h"
#include "lcd.h"

void Extern_LCD_Init();

void LCD_RenderButton();


struct button_display_handle {
    uint8_t *button_1;
    uint8_t button_1_len;
    uint8_t *button_2;
    uint8_t button_2_len;
    uint8_t *button_3;
    uint8_t button_3_len;
    uint8_t *button_4;
    uint8_t button_4_len;
    uint8_t isRendered;
};
struct command_line_handle {
    uint8_t now_line_index;
    uint8_t total_index;
    uint8_t enable;
};
struct Command_Line_Task {
    uint8_t *content;
    uint8_t now_page_id;
    uint8_t size;
    uint8_t x;
    uint8_t y;
    uint8_t isRandered;
};
struct process_handle {
    uint16_t start_x;
    uint16_t start_y;
    uint8_t width;
    uint8_t enable;
    uint16_t now_process;
    uint16_t set_process;
    uint16_t target_process;
    uint8_t isFinished;
    uint8_t enable_finish_callback;
    uint8_t isRendered;
    uint8_t forClearAndDisable;
    uint8_t visible;
    uint8_t boundary;
    uint8_t isBoundaryRendered;
    uint8_t showPresent;
    uint8_t last_present;
    uint8_t present;
    uint8_t display_present;
    uint8_t present_content[5];
    uint8_t *process_title;
    uint8_t title_updated;
    uint8_t current_process_title_len;
    uint8_t last_process_title_len;
    uint8_t clear_title;
};
struct TIMER_DISPLAY {
    uint8_t display_Year;
    uint8_t display_Month;
    uint8_t display_Day;
    uint8_t display_Hour;
    uint8_t display_Minute;
    //uint8_t display_Second;
    uint8_t set_Year;
    uint8_t set_Month;
    uint8_t set_Day;
    uint8_t set_Hour;
    uint8_t set_Minute;
    uint16_t start_x;
    uint16_t start_y;
    uint8_t enable;
    uint8_t isRendered;
};
struct FingerSensorState {
    uint8_t enable;
    uint8_t x;
    uint8_t y;
    uint8_t len;
    uint8_t renderedLen;
    uint8_t *content;
    uint8_t disable_for_clear;
    uint8_t isRendered;
};

struct log_show_handle {
    uint16_t line0;
    uint16_t line1;
    uint16_t line2;
    uint16_t line3;
    uint16_t line4;
    uint8_t enable;
    uint8_t isRendered;
    uint8_t for_Clear;
    uint8_t titled;
};
struct system_setting_handle {
    uint8_t enable;
    uint8_t isRendered;
    uint8_t for_Clear;
    uint8_t titled;
};
struct StateManager {
    uint8_t net_state;
    uint8_t door_state;
    uint8_t move_state;
    uint8_t isUpdated;
};

struct SensorStateManager {
    uint8_t enable;
    uint8_t net_state;
    uint8_t door_state;
    uint8_t move_state;
    uint8_t isStateUpdated;
    uint16_t radar_distance;
    uint16_t radar_signal;
    uint16_t isRadarUpdated;
    uint8_t for_Clear;
    uint8_t titled;

};


void enableSensorStateHandle();

void disableSensorStateHandle();

void handleSensorState(uint8_t clearMode);

void handleLCDStateManager();

void enable_setting_handle();

void disable_setting_handle();

void handle_setting_handle(uint8_t for_clear);

void updateFingerSensorData(uint8_t clearMode);

void disable_log_show_handle();

void initFingerSensorDisplay(uint8_t x, uint8_t y);

void
setCommandLineMode(uint8_t word_size, uint8_t *title, uint8_t *right_title, uint16_t title_x, uint16_t right_title_x,
                   uint8_t draw_line);

void LCD_ShowFlashPicture(uint16_t x, uint16_t y, uint16_t length, uint16_t width, uint32_t flash_address);

void addCommandLine(uint8_t *content);

void LCD_Extern_initProcessHandle(uint16_t start_x, uint16_t start_y, uint8_t width, uint16_t target_value);

void LCD_Extern_clearProcessHandle();

void showChineseString_16(uint16_t x, uint16_t y, uint8_t len, uint8_t *cn);

void LCD_Extern_setProcessValue(uint16_t value);

void LCD_Handle_Process();

void LCD_Handle_Main_Thread_Execute();

void setNETStateICON(uint8_t netState);

uint16_t LCD_Extern_getProcessValue();

uint8_t LCD_Extern_getProcessPresentValue();

void LCD_Extern_setPresentProcessValue(uint8_t present);

void kernal_init_done();

__weak void LCD_Callback_onProcessFinished();

uint8_t LCD_Extern_setProcessTitle(uint8_t *process_title, uint8_t present);

void LCD_DrawButton();

void LCD_HideButton();

void LCD_DrawTime(uint16_t x, uint16_t y);

void LCD_UpdateTime(uint8_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute);

void LCD_RenderTime();

void setLCDStatePicture(uint8_t state);

void disableFingerSensorDisplay();

void setMoveIcon(uint8_t moveState);

void setDoorIcon(uint8_t moveState);

void updateLogShowHandle(uint8_t clearMode);

void setLogShow(uint8_t slot, uint16_t id);

void enable_log_show_handle();